package com.humanmonth.home.component.page.portal
{
	import flash.events.Event;
	import flash.events.MouseEvent;
	
	import mx.collections.XMLListCollection;
	import mx.controls.Tree;
	import mx.core.DragSource;
	import mx.events.FlexEvent;
	import mx.managers.DragManager;
	
	public class CatalogTreeAs extends CatalogTree
	{
		public static const  TreeFormat:String="cTree";
		public static var catalogData:XML=
		<result>
		<catalog cname="交流平台" order="1">
		<catalog cname="外部邮件" order="13">
		<catalog cname="收件箱" order="141"></catalog>
		<catalog cname="发件箱" order="142"></catalog>	
		</catalog>
		<catalog cname="内部短信" order="12"></catalog>
		<catalog cname="手机短信" order="14"></catalog>
		<catalog cname="电子论坛" order="12"></catalog>
		<catalog cname="留言管理" order="14"></catalog>
		</catalog>
		<catalog cname="个人秘书" order="1">
		<catalog cname="通迅录" order="13"></catalog>
		<catalog cname="报刊征订" order="12"></catalog>
		<catalog cname="图书催还" order="14"></catalog>
		<catalog cname="新书预购" order="12"></catalog>
		<catalog cname="日程安排" order="14"></catalog>
		</catalog>
		<catalog cname="资料共享" order="1">
		<catalog cname="部门共享" order="13"></catalog>
		<catalog cname="公司共享" order="12"></catalog>
		</catalog>
		</result>;
		public function CatalogTreeAs()
		{
			super();
			this.addEventListener(FlexEvent.CREATION_COMPLETE,initData);
			this.addEventListener(FlexEvent.CREATION_COMPLETE,initListener);
		}
		
		/**
		 * 初始化draw操作 
		 */
		private function initDrag(event:MouseEvent):void{
			var tree:Tree=event.currentTarget as Tree;
			var dragSource:DragSource=new DragSource();
			dragSource.addData(tree,CatalogTreeAs.TreeFormat);
			DragManager.doDrag(tree,dragSource,event);
		}
		private function initListener(event:Event):void{
			this.catalogTree.addEventListener(MouseEvent.MOUSE_DOWN,initDrag);
		}
		/**
		 * 初始化数据 
		 */
		private function initData(event:Event):void{
			this.catalogTree.dataProvider=new XMLListCollection(catalogData.catalog);
			this.catalogTree.labelField="@cname";
			this.toolTip="把栏目拖放到右边";
		}
		
		
		
	}
}